import express from 'express'
import {
  createOrder,
  getOrder,
  getOrdersByPhone,
  getMyOrders,
  updateOrderStatus
} from '../controllers/orderController.js'
import {authenticateToken} from '../middleware/auth.js'

const router = express.Router()

// 创建订单（需要认证）
router.post('/', authenticateToken, createOrder)

// 获取当前用户的订单（需要认证）
router.get('/my', authenticateToken, getMyOrders)

// 获取订单详情
router.get('/:orderNo', getOrder)

// 根据手机号查询订单
router.get('/phone/:phone', getOrdersByPhone)

// 更新订单状态
router.put('/:orderNo/status', updateOrderStatus)

export default router
